--[[
User class.
Author: Jin Qing (http://blog.csdn.net/jq0123)
--]]

local User = {}
--[[
User = {
rpc_clt_id = 0,
account = "",
log = log:new("user." .. rpc_clt_id)  -- 使用rpc_clt_id安全，account无法控制长度和内容
timer_queue = c_timer_queue.CTimerQueue()  定时器队列，下线时会自动清空
}
--]]

local Log = require("log")

function User:new(rpc_clt_id, account)
	assert(rpc_clt_id > 0)
	local user = {
		rpc_clt_id = rpc_clt_id,
		account = account,
		log = Log:new("user." .. rpc_clt_id),
		timer_queue = c_timer_queue.CTimerQueue(),
	}
	user.log:debug("New user. account=%q", account)

	setmetatable(user, self)
	self.__index = self
	return user
end  -- new()

function User:is_valid_user()
	return true
end

function User:rpc_request(service_name, method_name, request, callback)
	assert("string" == type(service_name))
	assert("string" == type(method_name))
	assert("string" == type(request))
	assert(not callback or "function" == type(callback))
	self.log:debug("rpc request: %s.%s", service_name, method_name)
	c_rpc.request(self.rpc_clt_id, service_name, method_name, request, callback)
end  -- rpc_request

return User
